//
//  BTVPageViewController.h
//  BTVBCZLapp
//
//  Created by apple on 14-3-11.
//  Copyright (c) 2014年 jetsen. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "MBBaseController.h"
typedef NS_ENUM(NSUInteger, BTVPageViewOption)
{
    BTVPageViewOptionTabHeight,
    BTVPageViewOptionTabOffset,
    BTVPageViewOptionTabWidth,
    BTVPageViewOptionTabLocation,
    BTVPageViewOptionStartFromSecondTab,
    BTVPageViewOptionCenterCurrentTab
};

typedef NS_ENUM(NSUInteger, BTVPageViewComponent)
{
    BTVPageViewIndicator,
    BTVPageViewTabsView,
    BTVPageViewContent
};

@protocol BTVPageViewDataSource;
@protocol BTVPageViewDelegate;
@interface BTVPageViewController :MBBaseController
@property id<BTVPageViewDataSource> dataSource;
@property id<BTVPageViewDelegate> delegate;

#pragma mark BTVPageViewOptions
// Tab bar's height, defaults to 49.0
@property CGFloat tabHeight;
// Tab bar's offset from left, defaults to 56.0
@property CGFloat tabOffset;
// Any tab item's width, defaults to 128.0. To-do: make this dynamic
@property CGFloat tabWidth;

// 1.0: Top, 0.0: Bottom, changes tab bar's location in the screen
// Defaults to Top
@property CGFloat tabLocation;

// 1.0: YES, 0.0: NO, defines if view should appear with the second or the first tab
// Defaults to NO
@property CGFloat startFromSecondTab;

// 1.0: YES, 0.0: NO, defines if tabs should be centered, with the given tabWidth
// Defaults to NO
@property CGFloat centerCurrentTab;

@property NSMutableArray *tabWidthArray;

#pragma mark Colors
// Colors for several parts
@property UIColor *indicatorColor;
@property UIColor *tabsViewBackgroundColor;
@property UIColor *contentViewBackgroundColor;

#pragma mark Methods
// Reload all tabs and contents
- (void)reloadData;

- (UIViewController *)viewControllerAtIndex:(NSUInteger)index;

- (void)reloadNewData:(NSUInteger)index;

@end

#pragma mark dataSource
@protocol BTVPageViewDataSource <NSObject>

// Asks dataSource how many tabs will be
- (NSUInteger)numberOfTabsForBTVPageView:(BTVPageViewController *)BTVPageView;
// Asks dataSource to give a view to display as a tab item
// It is suggested to return a view with a clearColor background
// So that un/selected states can be clearly seen
- (UIView *)BTVPageView:(BTVPageViewController *)BTVPageView viewForTabAtIndex:(NSUInteger)index;

@optional
// The content for any tab. Return a view controller and BTVPageView will use its view to show as content
- (UIViewController *)BTVPageView:(BTVPageViewController *)BTVPageView contentViewControllerForTabAtIndex:(NSUInteger)index;
- (UIView *)BTVPageView:(BTVPageViewController *)BTVPageView contentViewForTabAtIndex:(NSUInteger)index;

@end

#pragma mark delegate
@protocol BTVPageViewDelegate <NSObject>

@optional
// delegate object must implement this method if wants to be informed when a tab changes
- (void)BTVPageView:(BTVPageViewController *)BTVPageView didChangeTabToIndex:(NSUInteger)index;

- (void)BTVPageView:(BTVPageViewController *)BTVPageView didChangeTabFromIndex:(NSUInteger)fromIndex toIndex:(NSUInteger)toIndex;


// Every time - reloadData called, BTVPageView will ask its delegate for option values
// So you don't have to set options from BTVPageView itself
- (CGFloat)BTVPageView:(BTVPageViewController *)BTVPageView valueForOption:(BTVPageViewOption)option withDefault:(CGFloat)value;
/*
 * Use this method to customize the look and feel.
 * BTVPageView will ask its delegate for colors for its components.
 * And if they are provided, it will use them, otherwise it will use default colors.
 * Also not that, colors for tab and content views will change the tabView's and contentView's background
 * (you should provide these views with a clearColor to see the colors),
 * and indicator will change its own color.
 */
- (UIColor *)BTVPageView:(BTVPageViewController *)BTVPageView colorForComponent:(BTVPageViewComponent)component withDefault:(UIColor *)color;

- (NSMutableArray *)widthOfTabsForBTVPageView:(BTVPageViewController *)BTVPageView;

@end


